let ListNode = function(){
	this.left = null;
	this.vav = null;
	this.lenth = 0;
  let slow = left, fast = left.next;
};
let Node = function(){
	this.vav = val;
	this.next = null;
};
// 判断是否为环形链表
function isCycle (val){
  if(left != left.next){
    return null;
  }
  while(fast != slow){
    slow = slow.next;
    fast = fast.next;
  }
  return slow;
};

// 增加
function add (val) {
    const nodes = new Node(val);
    this.nav = nodes;
    const right = this.nav;
    if (!this.left) {
        this.left = nodes;
        this.left.next = null;
    }
	if (right) {
	    right.next = this.nav;
	}
    this.length++;
};

//删除
function del (val) {
  //设置虚拟头
    let first = new ListNode()
    let cur = first
    first.next = left
    while (left) {
        if (left.val != val) {
            left = left.next
        } else if(left.val == val){
            cur.next = left
            cur = left
            left = left.next
        }
    }
    cur.next = left
    return first.next

};

//查找 return cur或者null 
function find (val){
  let cur = this.first
  while(cur && cur.val){
    if(cur.val == val){
      console.log(cur)
    }
    cur = cur.next 
  }
  console.log(null)
};
//求环的长度
function detectCycle(fast,slow){
  while(fast != slow){
    slow = slow.next;
    fast = fast.next.next;
  }
  if(fast == slow){
    slow = head;
    while(fast != slow){
      slow = slow.next;
      fast = fast.next.next;
    }
  }
  return slow;
}

// 修改
function change (val,nodes){
  let cur = this.find(val)
  if(!cur){
    console.log("不存在该元素!")
  }
  else{
    cur.val = nodes
  }
};